package flex.cc.fenfa.enums;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import java.util.List;
import java.util.Map;

/**
*
* @author WANGCONG
* 2021年10月13日下午2:33:18
* @desc 分发规则返回Msg
*/
public enum FenFaMsgEnum {

	ONE("1", "规则名称已存在"),
	
    TWO("2", "没有匹配的规则"),
    
    THREE("3", "没有匹配的服务商");
	
    String type;
    String name;

    FenFaMsgEnum(String type, String name) {
        this.type = type;
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public String getName() {
        return name;
    }

    public static String getName(String type) {
        for (FenFaMsgEnum ele : FenFaMsgEnum.values()) {
            if (type.equals(ele.getType())) {
                return ele.getName();
            }
        }
        return "未知";
    }

    public static FenFaMsgEnum getEnum(String type) {
        for (FenFaMsgEnum ele : FenFaMsgEnum.values()) {
            if (type.equals(ele.getType())) {
                return ele;
            }
        }
		return null;
    }

    public static List<Map<String, Object>> getList() {
        List<Map<String, Object>> list = Lists.newArrayList();
        for (FenFaMsgEnum ele : FenFaMsgEnum.values()) {
            Map<String, Object> map = Maps.newHashMap();
            map.put("key", ele.getType());
            map.put("value", ele.getName());
            list.add(map);
        }
        return list;
    }
}
